#include "StdAfx.h"
#include "DataTypeConvertion.h"


CDataTypeConvertion::CDataTypeConvertion(void)
{
}


CDataTypeConvertion::~CDataTypeConvertion(void)
{
}


// DataTypeEnum
bool CDataTypeConvertion::DataTypeEnum(const int type, std::string& resultdata)
{
	bool bresult = true;
	switch(type)
	{
	//adInteger
	//Indicates a four-byte signed integer (DBTYPE_I4).
	case 3:
	//adDouble
	//Indicates a double-precision floating-point value (DBTYPE_R8).
	case 5:
	//adCurrency
	//Indicates a currency value (DBTYPE_CY). Currency is a fixed-point number with four digits to the right of the decimal point. It is stored in an eight-byte signed integer scaled by 10,000.
	case 6:
	//adError
	//Indicates a 32-bit error code (DBTYPE_ERROR).
	case 10:
	//adBoolean
	//Indicates a Boolean value (DBTYPE_BOOL).
	case 11:
	//adDecimal
	//Indicates an exact numeric value with a fixed precision and scale (DBTYPE_DECIMAL).
	case 14:
	//adBigInt
	//Indicates an eight-byte signed integer (DBTYPE_I8).
	case 20:
	//adFileTime
	//Indicates a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (DBTYPE_FILETIME).
	case 64:
	//adNumeric
	//Indicates an exact numeric value with a fixed precision and scale (DBTYPE_NUMERIC).
	case 131:
	//adPropVariant
	//Indicates an Automation PROPVARIANT (DBTYPE_PROP_VARIANT).
	case 138:
	//adSingle
	//Indicates a single-precision floating-point value (DBTYPE_R4).
	case 4:
	//adSmallInt
	//Indicates a two-byte signed integer (DBTYPE_I2).
	case 2:
	//adTinyInt
	//Indicates a one-byte signed integer (DBTYPE_I1).
	case 16:
	//adUnsignedBigInt
	//Indicates an eight-byte unsigned integer (DBTYPE_UI8).
	case 21:
	//adUnsignedInt
	//Indicates a four-byte unsigned integer (DBTYPE_UI4).
	case 19:
	//adUnsignedSmallInt
	//Indicates a two-byte unsigned integer (DBTYPE_UI2).
	case 18:
	//adUnsignedTinyInt
	//Indicates a one-byte unsigned integer (DBTYPE_UI1).
	case 17:
	//adUserDefined
	//Indicates a user-defined variable (DBTYPE_UDT).
	case 132:
	//adVarNumeric
	//Indicates a numeric value.
	case 139:		
		break;

		
	//adEmpty
	//Specifies no value (DBTYPE_EMPTY).
	case 0:
	//adDate
	//Indicates a date value (DBTYPE_DATE). A date is stored as a double, the whole part of which is the number of days since December 30, 1899, and the fractional part of which is the fraction of a day.
	case 7:
	//adBSTR
	//Indicates a null-terminated character string (Unicode) (DBTYPE_BSTR).
	case 8:
	//adGUID
	//Indicates a globally unique identifier (GUID) (DBTYPE_GUID).
	case 72:
	//adChar
	//Indicates a string value (DBTYPE_STR).
	case 129:
	//adWChar
	//Indicates a null-terminated Unicode character string (DBTYPE_WSTR).
	case 130:
	//adDBDate
	//Indicates a date value (yyyymmdd) (DBTYPE_DBDATE).
	case 133:
	//adDBTime
	//Indicates a time value (hhmmss) (DBTYPE_DBTIME).
	case 134:
	//adDBTimeStamp
	//Indicates a date/time stamp (yyyymmddhhmmss plus a fraction in billionths) (DBTYPE_DBTIMESTAMP).
	case 135:
	//adChapter
	//Indicates a four-byte chapter value that identifies rows in a child rowset (DBTYPE_HCHAPTER).
	case 136:
	//adVarChar
	//Indicates a string value.
	case 200:
	//adLongVarChar
	//Indicates a long string value.
	case 201:
	//adVarWChar
	//Indicates a null-terminated Unicode character string.
	case 202:
	//adLongVarWChar
	//Indicates a long null-terminated Unicode string value.
	case 203:
		resultdata = "'" + resultdata + "'";
		break;
	//AdArray
	//A flag value, always combined with another data type constant, that indicates an array of the other data type. Does not apply to ADOX.
	case 0x2000:
	//adIDispatch
	//Indicates a pointer to an IDispatch interface on a COM object (DBTYPE_IDISPATCH).
	//Note   This data type is currently not supported by ADO. Usage may cause unpredictable results.
	case 9:
	//adVariant
	//Indicates an Automation Variant (DBTYPE_VARIANT).
	//Note    This data type is currently not supported by ADO. Usage may cause unpredictable results.
	case 12:
	//adIUnknown
	//Indicates a pointer to an IUnknown interface on a COM object (DBTYPE_IUNKNOWN).
	//Note    This data type is currently not supported by ADO. Usage may cause unpredictable results.
	case 13:
	//adBinary
	//Indicates a binary value (DBTYPE_BYTES).
	case 128:
	//adVarBinary
	//Indicates a binary value.
	case 204:
	//adLongVarBinary
	//Indicates a long binary value.
	case 205:
		bresult = false;
		break;
	}
	return bresult;
}


// DataTypeEnum
bool CDataTypeConvertion::DataTypeEnum(const int type, std::wstring& resultdata)
{
	bool bresult = true;
	switch(type)
	{
	//adInteger
	//Indicates a four-byte signed integer (DBTYPE_I4).
	case 3:
	//adDouble
	//Indicates a double-precision floating-point value (DBTYPE_R8).
	case 5:
	//adCurrency
	//Indicates a currency value (DBTYPE_CY). Currency is a fixed-point number with four digits to the right of the decimal point. It is stored in an eight-byte signed integer scaled by 10,000.
	case 6:
	//adError
	//Indicates a 32-bit error code (DBTYPE_ERROR).
	case 10:
	//adBoolean
	//Indicates a Boolean value (DBTYPE_BOOL).
	case 11:
	//adDecimal
	//Indicates an exact numeric value with a fixed precision and scale (DBTYPE_DECIMAL).
	case 14:
	//adBigInt
	//Indicates an eight-byte signed integer (DBTYPE_I8).
	case 20:
	//adFileTime
	//Indicates a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (DBTYPE_FILETIME).
	case 64:
	//adNumeric
	//Indicates an exact numeric value with a fixed precision and scale (DBTYPE_NUMERIC).
	case 131:
	//adPropVariant
	//Indicates an Automation PROPVARIANT (DBTYPE_PROP_VARIANT).
	case 138:
	//adSingle
	//Indicates a single-precision floating-point value (DBTYPE_R4).
	case 4:
	//adSmallInt
	//Indicates a two-byte signed integer (DBTYPE_I2).
	case 2:
	//adTinyInt
	//Indicates a one-byte signed integer (DBTYPE_I1).
	case 16:
	//adUnsignedBigInt
	//Indicates an eight-byte unsigned integer (DBTYPE_UI8).
	case 21:
	//adUnsignedInt
	//Indicates a four-byte unsigned integer (DBTYPE_UI4).
	case 19:
	//adUnsignedSmallInt
	//Indicates a two-byte unsigned integer (DBTYPE_UI2).
	case 18:
	//adUnsignedTinyInt
	//Indicates a one-byte unsigned integer (DBTYPE_UI1).
	case 17:
	//adUserDefined
	//Indicates a user-defined variable (DBTYPE_UDT).
	case 132:
	//adVarNumeric
	//Indicates a numeric value.
	case 139:		
		break;

		
	//adEmpty
	//Specifies no value (DBTYPE_EMPTY).
	case 0:
	//adDate
	//Indicates a date value (DBTYPE_DATE). A date is stored as a double, the whole part of which is the number of days since December 30, 1899, and the fractional part of which is the fraction of a day.
	case 7:
	//adBSTR
	//Indicates a null-terminated character string (Unicode) (DBTYPE_BSTR).
	case 8:
	//adGUID
	//Indicates a globally unique identifier (GUID) (DBTYPE_GUID).
	case 72:
	//adChar
	//Indicates a string value (DBTYPE_STR).
	case 129:
	//adWChar
	//Indicates a null-terminated Unicode character string (DBTYPE_WSTR).
	case 130:
	//adDBDate
	//Indicates a date value (yyyymmdd) (DBTYPE_DBDATE).
	case 133:
	//adDBTime
	//Indicates a time value (hhmmss) (DBTYPE_DBTIME).
	case 134:
	//adDBTimeStamp
	//Indicates a date/time stamp (yyyymmddhhmmss plus a fraction in billionths) (DBTYPE_DBTIMESTAMP).
	case 135:
	//adChapter
	//Indicates a four-byte chapter value that identifies rows in a child rowset (DBTYPE_HCHAPTER).
	case 136:
	//adVarChar
	//Indicates a string value.
	case 200:
	//adLongVarChar
	//Indicates a long string value.
	case 201:
	//adVarWChar
	//Indicates a null-terminated Unicode character string.
	case 202:
	//adLongVarWChar
	//Indicates a long null-terminated Unicode string value.
	case 203:
		resultdata = _T("'") + resultdata + _T("'");
		break;
	//AdArray
	//A flag value, always combined with another data type constant, that indicates an array of the other data type. Does not apply to ADOX.
	case 0x2000:
	//adIDispatch
	//Indicates a pointer to an IDispatch interface on a COM object (DBTYPE_IDISPATCH).
	//Note   This data type is currently not supported by ADO. Usage may cause unpredictable results.
	case 9:
	//adVariant
	//Indicates an Automation Variant (DBTYPE_VARIANT).
	//Note    This data type is currently not supported by ADO. Usage may cause unpredictable results.
	case 12:
	//adIUnknown
	//Indicates a pointer to an IUnknown interface on a COM object (DBTYPE_IUNKNOWN).
	//Note    This data type is currently not supported by ADO. Usage may cause unpredictable results.
	case 13:
	//adBinary
	//Indicates a binary value (DBTYPE_BYTES).
	case 128:
	//adVarBinary
	//Indicates a binary value.
	case 204:
	//adLongVarBinary
	//Indicates a long binary value.
	case 205:
		bresult = false;
		break;
	}
	return bresult;
}

bool CDataTypeConvertion::DataTypeEnum(const int type, CString& resultdata)
{
	bool bresult = true;
	switch(type)
	{
	//adInteger
	//Indicates a four-byte signed integer (DBTYPE_I4).
	case 3:
	//adDouble
	//Indicates a double-precision floating-point value (DBTYPE_R8).
	case 5:
	//adCurrency
	//Indicates a currency value (DBTYPE_CY). Currency is a fixed-point number with four digits to the right of the decimal point. It is stored in an eight-byte signed integer scaled by 10,000.
	case 6:
	//adError
	//Indicates a 32-bit error code (DBTYPE_ERROR).
	case 10:
	//adBoolean
	//Indicates a Boolean value (DBTYPE_BOOL).
	case 11:
	//adDecimal
	//Indicates an exact numeric value with a fixed precision and scale (DBTYPE_DECIMAL).
	case 14:
	//adBigInt
	//Indicates an eight-byte signed integer (DBTYPE_I8).
	case 20:
	//adFileTime
	//Indicates a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (DBTYPE_FILETIME).
	case 64:
	//adNumeric
	//Indicates an exact numeric value with a fixed precision and scale (DBTYPE_NUMERIC).
	case 131:
	//adPropVariant
	//Indicates an Automation PROPVARIANT (DBTYPE_PROP_VARIANT).
	case 138:
	//adSingle
	//Indicates a single-precision floating-point value (DBTYPE_R4).
	case 4:
	//adSmallInt
	//Indicates a two-byte signed integer (DBTYPE_I2).
	case 2:
	//adTinyInt
	//Indicates a one-byte signed integer (DBTYPE_I1).
	case 16:
	//adUnsignedBigInt
	//Indicates an eight-byte unsigned integer (DBTYPE_UI8).
	case 21:
	//adUnsignedInt
	//Indicates a four-byte unsigned integer (DBTYPE_UI4).
	case 19:
	//adUnsignedSmallInt
	//Indicates a two-byte unsigned integer (DBTYPE_UI2).
	case 18:
	//adUnsignedTinyInt
	//Indicates a one-byte unsigned integer (DBTYPE_UI1).
	case 17:
	//adUserDefined
	//Indicates a user-defined variable (DBTYPE_UDT).
	case 132:
	//adVarNumeric
	//Indicates a numeric value.
	case 139:		
		break;

		
	//adEmpty
	//Specifies no value (DBTYPE_EMPTY).
	case 0:
	//adDate
	//Indicates a date value (DBTYPE_DATE). A date is stored as a double, the whole part of which is the number of days since December 30, 1899, and the fractional part of which is the fraction of a day.
	case 7:
	//adBSTR
	//Indicates a null-terminated character string (Unicode) (DBTYPE_BSTR).
	case 8:
	//adGUID
	//Indicates a globally unique identifier (GUID) (DBTYPE_GUID).
	case 72:
	//adChar
	//Indicates a string value (DBTYPE_STR).
	case 129:
	//adWChar
	//Indicates a null-terminated Unicode character string (DBTYPE_WSTR).
	case 130:
	//adDBDate
	//Indicates a date value (yyyymmdd) (DBTYPE_DBDATE).
	case 133:
	//adDBTime
	//Indicates a time value (hhmmss) (DBTYPE_DBTIME).
	case 134:
	//adDBTimeStamp
	//Indicates a date/time stamp (yyyymmddhhmmss plus a fraction in billionths) (DBTYPE_DBTIMESTAMP).
	case 135:
	//adChapter
	//Indicates a four-byte chapter value that identifies rows in a child rowset (DBTYPE_HCHAPTER).
	case 136:
	//adVarChar
	//Indicates a string value.
	case 200:
	//adLongVarChar
	//Indicates a long string value.
	case 201:
	//adVarWChar
	//Indicates a null-terminated Unicode character string.
	case 202:
	//adLongVarWChar
	//Indicates a long null-terminated Unicode string value.
	case 203:
		resultdata = _T("'") + resultdata + _T("'");
		break;
	//AdArray
	//A flag value, always combined with another data type constant, that indicates an array of the other data type. Does not apply to ADOX.
	case 0x2000:
	//adIDispatch
	//Indicates a pointer to an IDispatch interface on a COM object (DBTYPE_IDISPATCH).
	//Note   This data type is currently not supported by ADO. Usage may cause unpredictable results.
	case 9:
	//adVariant
	//Indicates an Automation Variant (DBTYPE_VARIANT).
	//Note    This data type is currently not supported by ADO. Usage may cause unpredictable results.
	case 12:
	//adIUnknown
	//Indicates a pointer to an IUnknown interface on a COM object (DBTYPE_IUNKNOWN).
	//Note    This data type is currently not supported by ADO. Usage may cause unpredictable results.
	case 13:
	//adBinary
	//Indicates a binary value (DBTYPE_BYTES).
	case 128:
	//adVarBinary
	//Indicates a binary value.
	case 204:
	//adLongVarBinary
	//Indicates a long binary value.
	case 205:
		bresult = false;
		break;
	}
	return bresult;
}